package com.vogue.sms.modules.monitor.controller;

import java.util.Arrays;
import java.util.Map;

import com.vogue.sms.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.vogue.sms.modules.monitor.entity.RecordDataEntity;
import com.vogue.sms.modules.monitor.service.RecordDataService;
import com.vogue.sms.common.utils.PageUtils;
import com.vogue.sms.common.utils.R;



/**
 * 数据记录
 *
 * @author George
 * @email qiaozhi_china@163.com
 * @date 2018-12-02 23:04:30
 */
@RestController
@RequestMapping("monitor/recorddata")
public class RecordDataController {
    @Autowired
    private RecordDataService recordDataService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("monitor:recorddata:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = recordDataService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("monitor:recorddata:info")
    public R info(@PathVariable("id") Integer id){
        RecordDataEntity recordData = recordDataService.selectById(id);

        return R.ok().put("recordData", recordData);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("monitor:recorddata:save")
    public R save(@RequestBody RecordDataEntity recordData){
        recordDataService.insert(recordData);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("monitor:recorddata:update")
    public R update(@RequestBody RecordDataEntity recordData){
        ValidatorUtils.validateEntity(recordData);
        recordDataService.updateAllColumnById(recordData);//全部更新
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("monitor:recorddata:delete")
    public R delete(@RequestBody Integer[] ids){
        recordDataService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }

}
